<template>
    <div>
        <div>userLocation: {{userLocation}}</div>
        <div>userGeolocation: {{userGeolocation.longitude}}，{{userGeolocation.latitude}}</div>
        <div><el-button @click="updateUserLocation">在子组件里面更新注入的location</el-button></div>
    </div>
</template>

<script>
import { inject } from 'vue'
export default {
    setup () {
        const userLocation = inject('location', '广州') // 后面的是默认值
        const userGeolocation = inject('geolocation')
        const updateUserLocation = inject('updateLocation')

        return {
            userLocation,
            userGeolocation,
            updateUserLocation
        }
    }
}
</script>

<style lang="scss" scoped>

</style>